package com.controller.xsxt;

import com.entity.common.ApiResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.xsxt.PrizeSetService;
import com.entity.xsxt.PrizeSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by System on 2019/03/15 09:17:28.
 */
@RestController
@RequestMapping("prizeSet")
public class PrizeSetController {

    @Autowired
    private PrizeSetService prizeSetService;

    @RequestMapping("/getPageList")
    public Map<String,Object> getPageList(@RequestParam(value = "pager.pageNo",defaultValue ="1" )  Integer pageNum,
                @RequestParam(value = "pager.pageSize",defaultValue ="10" ) Integer pageSize,PrizeSet prizeSet){
        Map<String, Object> map=new HashMap<>();
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<PrizeSet> pageInfo = new PageInfo<>(prizeSetService.getPageList(prizeSet));
        map.put("rows",pageInfo.getList());
        map.put("pager.totalRows", pageInfo.getTotal());
        map.put("pager.pageNo",pageNum);
        return  map;
    }

    @RequestMapping("/addPrizeSet")
    public ApiResult addPrizeSet(PrizeSet prizeSet){
        return prizeSetService.addPrizeSet(prizeSet);
    }

    @RequestMapping("/deletePrizeSet")
    public ApiResult deletePrizeSet(int id){
        return prizeSetService.deletePrizeSet(id);
    }

    @RequestMapping("/getPrizeSetById")
    public ApiResult getPrizeSetById(Integer id){
        return prizeSetService.getPrizeSetById(id);
    }

    @RequestMapping("/editPrizeSet")
    public ApiResult editPrizeSet(PrizeSet prizeSet){
        return prizeSetService.editPrizeSet(prizeSet);
    }

}
